<?php
/**
 * File
 * 
 * @category	Log
 * @package		dayscript.log.adapter
 * @subpackage	
 * @author		Nelson Daza <ndaza@dayscript.com>
 * @copyright	2009 Dayscript Ltda.
 * @license		
 * @version		1.0
 * @version		$Revision: 0 $
 * @filesource	
 * @link		http://www.dayscript.com
 * @link		{docsLink}
 * @uses		
 * @since		1.0
 * @modifiedby	$LastChangedBy: Nelson Daza $
 * @modified	$Date: 2009-09-02 $
 */

namespace dayscript\log\adapter;

/**
 * File
 * 
 * @category	Log
 * @package		dayscript.log.adapter
 * @subpackage	
 * @author		Nelson Daza <ndaza@dayscript.com>
 * @copyright	2009 Dayscript Ltda.
 * @license		
 * @version		1.0
 * @link		http://www.dayscript.com
 * @link		{docsLink}
 * @uses		\dayscript\Map, \dayscript\log\Logger
 * @since		1.0
 * @modifiedby	$LastChangedBy: Nelson Daza $
 * @modified	$Date: 2009-09-03 $
 */
class File extends \dayscript\log\Logger	{
	/**
	 * File to a server file
	 * @var \filesystem\FileSystem
	 */
	private $file = null;
	/**
	 * File constructor
	 * @param string $name File identificator
	 * @param array|\dayscript\Map $config File configuration
	 * @return Logger
	 */
	public function __construct( $name, \dayscript\Map $config )	{
		parent::__construct( $name, $config );
		if( $config )
			$this->file = $config->get( 'file' );
		if( $this->file )	{
			if( !\file_exists( \dirname( $this->file ) ) )	{
				\trigger_error( 'Selected log\'s Folder "' . $this->file . '" does not exists. ', \E_USER_WARNING );
				$this->file = null;
			}
		}
	}
	/**
	 * @see \dayscript\log\Logger
	 */
	public function internalLog( $message, $actualThreshold, $filterThreshold )	{
		\error_log( \rtrim( $message ), ( $this->file ? 3 : 0 ), $this->file );
	}
	/**
	 * @see \dayscript\log\Logger
	 */
	public function flush( )	{
		
	}
}